package com.geese.module.admin.controller;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.geese.common.BaseController;
import com.geese.common.constants.Constants;
import com.geese.common.entity.OperationLog;
import com.geese.common.vo.Page;
import com.geese.common.vo.Paginator;
import com.geese.module.admin.service.OperationLogService;
import com.geese.module.admin.vo.OperationLogQuery;
import com.google.common.collect.Maps;

/**
 * @author YeFangYi
 */
@Controller
@RequestMapping(value = "/admin")
@Scope("prototype")
public class OperationLogController extends BaseController {

	@Autowired
	private OperationLogService operationLogService;

	/**
	 * 获取资源列表
	 */
	@RequiresPermissions("log:view")
	@GetMapping("/operation/listInPage")
	@ResponseBody
	public String listOperationLog(OperationLogQuery query) {
		Page page = getPageInfo(query);
    	Paginator<OperationLog> pageList = operationLogService.listAllByQuery(query, page);
    	Map<String, Object> result = Maps.newHashMap();
    	result.put(Constants.PAGE_INFO, pageList.getPageResult());
    	result.put("operationLogList", pageList.getResults());
		return response(result);
	}

}
